
package me.landery.modules.sinco.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.landery.base.BaseEntity;
import me.landery.modules.system.domain.User;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author landery
* @date 2022-06-23
**/
@Entity
@Data
@Table(name="sinco_profit")
public class Profit extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Long id;

//    @Column(name = "rid",nullable = false)
    @NotNull
    @ApiModelProperty(value = "推荐码id")
    @ManyToOne
    @JoinColumn(name = "rid")
    private Recommend recommend;

    @NotNull
    @ApiModelProperty(value = "使用人id")
    @ManyToOne
    @JoinColumn(name = "uid")
    private User user;

    @NotNull
    @ApiModelProperty(value = "收益配置id", hidden = true)
    @ManyToOne
    @JoinColumn(name = "pro_id")
    private ProfitConfig profitConfig;

//    @Column(name = "profit_type")
//    @ApiModelProperty(value = "收益类型")
//    private Integer profitType;

    @Column(name = "profit")
    @ApiModelProperty(value = "收益金额")
    private Double profit;

    @Column(name = "cost")
    @ApiModelProperty(value = "使用人花费")
    private Double cost;

    public void copy(Profit source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}